Framework
Interactable entities that can be held in inventories.
Items are objects that are contained inside of an Inventory, or as standalone entities if they are dropped in the world. They usually have functionality that provides more gameplay aspects to the schema.
For an item to have an actual presence, they need to be instanced (usually by spawning them). Items describe the
properties, while instances are a clone of these properties that can have their own unique data (e.g an ID card will have the
same name but different numerical IDs). You can think of items as the class, while instances are objects of the Item
class.
Functions
itemMeta:__eq(other)
Returns true if this item is equal to another item. Internally, this checks item IDs.
Parameters
-
other
Item
Item to compare to
Returns
-
bool
Whether or not this item is equal to the given item
Example Usage
print(lia.item.instances[1] == lia.item.instances[2])
> falsefunction ITEM:__eq(other)
itemMeta:__tostring()
Returns a string representation of this item.
Returns
-
string
String representation
Example Usage
print(lia.item.instances[1])
> "item[1]"
itemMeta:addQuantity(quantity, receivers, noCheckEntity)
Adds a specified quantity to the item's current quantity.
Parameters
-
quantity
Integer
The quantity to add.
-
receivers
Table
optional
Players who should receive updates about the quantity change.
-
noCheckEntity
Boolean
optional
If true, entity checks will be skipped.
itemMeta:call(method, client, entity, ...)
Calls one of the item's methods.
Parameters
-
method
String
The method to be called
-
client
Player
The client to pass when calling the method, if applicable
-
entity
Entity
The eneity to pass when calling the method, if applicable
-
...
Table
Arguments to pass to the method
Returns
-
any
The values returned by the method
itemMeta:delete()
Deletes the item from the database and performs cleanup.
Returns
-
any
(deferred) A deferred object representing the asynchronous operation of deleting the item from the database.
itemMeta:destroy()
Destroys the item instance, removing it from the game world and notifying all clients.
itemMeta:getData(key, default)
Returns the value stored on a key within the item's data.
Parameters
-
key
String
The key in which the value is stored
-
default
optional
The value to return in case there is no value stored in the key
Returns
-
any
The value stored within the key
itemMeta:getDesc()
Returns the description of the item.
Returns
-
string
The description of the item
itemMeta:getDesc()
Returns the description of the item.
Returns
-
any
string The description of the item
itemMeta:getEntity()
Returns the item's entity.
Returns
-
entity
The entity of the item
itemMeta:getID()
Returns this item's database ID. This is guaranteed to be unique.
Returns
-
number
Unique ID of item
itemMeta:getModel()
Returns the model of the item.
Returns
-
string
The model of the item
itemMeta:getName()
Returns the name of the item.
Returns
-
any
string The name of the item
itemMeta:getName()
Returns the name of the item.
Returns
-
string
The name of the item
itemMeta:getOwner()
Returns the player that owns this item.
Returns
-
player
Player owning this item
itemMeta:getPrice()
Returns the price of the item.
Returns
-
string
The price of the item
itemMeta:getQuantity()
Returns the quantity of the item.
Returns
-
number
The quantity of the item
itemMeta:getSkin()
Returns the skin of the item.
Returns
-
number
The skin of the item
itemMeta:hook(name, func)
Changes the function called on specific events for the item.
Parameters
-
name
String
The name of the hook
-
func
Function
The function to call once the event occurs
itemMeta:interact(action, client, entity, data)
Performs an interaction action with the item.
Parameters
-
action
String
The interaction action to perform.
-
client
Player
The player performing the interaction.
-
entity
Entity
The entity associated with the interaction, if any.
-
data
Table
optional
Additional data related to the interaction.
Returns
-
any
bool Whether the interaction was successful.
itemMeta:onDisposed()
Gets called upon destroying an item.
itemMeta:onInstanced()
Gets called upon creating (instancing) an item.
itemMeta:onRemoved()
Gets called upon removing an item.
itemMeta:onRestored()
Gets called upon restoring an item.
itemMeta:onSync()
Gets called upon syncing an item.
itemMeta:postHook(name, func)
Changes the function called after hooks for specific events for the item.
Parameters
-
name
String
The name of the hook
-
func
Function
The function to call after the original hook was called
itemMeta:print(detail)
A utility function which prints the item's details.
Parameters
-
detail
Boolean
default: false
Whether additional detail should be printed or not(Owner, X position, Y position)
itemMeta:printData()
A utility function printing the item's stored data.
itemMeta:remove(bNoReplication, bNoDelete)
Removes the item.
Parameters
-
bNoReplication
Boolean
Whether or not the item's removal should not be replicated.
-
bNoDelete
Boolean
Whether or not the item should not be fully deleted
Returns
-
bool
Whether the item was successfully deleted or not
itemMeta:removeFromInventory(preserveItem)
Removes the item from its current inventory.
Parameters
-
preserveItem
Boolean
optional
If true, the item is not fully deleted from the database.
Returns
-
any
(deferred) A deferred object representing the asynchronous operation of removing the item.
itemMeta:setData(key, value, receivers, noSave, noCheckEntity)
Sets a key within the item's data.
Parameters
-
key
String
The key to store the value within
-
value
default: nil
The value to store within the key
-
receivers
Table
default: nil
The players to replicate the data on
-
noSave
Boolean
default: false
Whether to disable saving the data on the database or not
-
noCheckEntity
Boolean
default: false
Whether to disable setting the data on the entity, if applicable
itemMeta:setQuantity(quantity, receivers, noCheckEntity)
Sets the quantity of the item to the specified value.
Parameters
-
quantity
Integer
The new quantity value.
-
receivers
Table
optional
Players who should receive updates about the quantity change.
-
noCheckEntity
Boolean
optional
If true, entity checks will be skipped.
itemMeta:spawn(position, angles)
Spawn an item entity based off the item table.
Parameters
-
position
Vector
The position in which the item's entity will be spawned
-
angles
Angle
The angles at which the item's entity will spawn
Returns
-
entity
The spawned entity
itemMeta:sync(recipient)
Synchronizes the item data with the specified recipient or broadcasts it to all clients if no recipient is specified.
Parameters
-
recipient
Player
The player to whom the item data should be synchronized. If set to nil, the data is broadcasted to all clients.
itemMeta:transfer(newInventory, bBypass)
Transfers the item to another inventory.
Parameters
-
newInventory
The inventory to which the item should be transferred.
-
bBypass
Boolean
Whether to bypass access checks for transferring the item.
Returns
-
bool
Whether the item was successfully transferred or not.